Create Index
curl --request POST \
--url https://api.sophra.org/api/cortex/indices \
--header 'Content-Type: application/json' \
--data '
{
"name": "{{test_index_name}}",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"default": {
"type": "standard",
"stopwords": "_english_"
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "standard",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"content": {
"type": "text",
"analyzer": "standard",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"abstract": {
"type": "text",
"analyzer": "standard",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"embeddings": {
"type": "dense_vector",
"dims": 3072,
"index": true,
"similarity": "cosine",
"index_options": {
"type": "hnsw",
"m": 16,
"ef_construction": 100
}
},
"authors": {
"type": "keyword"
},
"tags": {
"type": "keyword"
},
"source": {
"type": "keyword"
},
"processing_status": {
"type": "keyword"
},
"metadata": {
"type": "object",
"enabled": true
},
"evaluation_score": {
"properties": {
"relevance": {
"type": "float"
},
"credibility": {
"type": "float"
},
"clarity": {
"type": "float"
},
"actionability": {
"type": "float"
},
"aggregate": {
"type": "float"
}
}
},
"created_at": {
"type": "date"
},
"updated_at": {
"type": "date"
},
"vectorized_at": {
"type": "date"
}
}
}
}
'import requests
url = "https://api.sophra.org/api/cortex/indices"
payload = {
"name": "{{test_index_name}}",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": { "analyzer": { "default": {
"type": "standard",
"stopwords": "_english_"
} } }
},
"mappings": { "properties": {
"title": {
"type": "text",
"analyzer": "standard",
"fields": { "keyword": {
"type": "keyword",
"ignore_above": 256
} }
},
"content": {
"type": "text",
"analyzer": "standard",
"fields": { "keyword": {
"type": "keyword",
"ignore_above": 256
} }
},
"abstract": {
"type": "text",
"analyzer": "standard",
"fields": { "keyword": {
"type": "keyword",
"ignore_above": 256
} }
},
"embeddings": {
"type": "dense_vector",
"dims": 3072,
"index": True,
"similarity": "cosine",
"index_options": {
"type": "hnsw",
"m": 16,
"ef_construction": 100
}
},
"authors": { "type": "keyword" },
"tags": { "type": "keyword" },
"source": { "type": "keyword" },
"processing_status": { "type": "keyword" },
"metadata": {
"type": "object",
"enabled": True
},
"evaluation_score": { "properties": {
"relevance": { "type": "float" },
"credibility": { "type": "float" },
"clarity": { "type": "float" },
"actionability": { "type": "float" },
"aggregate": { "type": "float" }
} },
"created_at": { "type": "date" },
"updated_at": { "type": "date" },
"vectorized_at": { "type": "date" }
} }
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '{{test_index_name}}',
settings: {
number_of_shards: 1,
number_of_replicas: 1,
analysis: {analyzer: {default: {type: 'standard', stopwords: '_english_'}}}
},
mappings: {
properties: {
title: {
type: 'text',
analyzer: 'standard',
fields: {keyword: {type: 'keyword', ignore_above: 256}}
},
content: {
type: 'text',
analyzer: 'standard',
fields: {keyword: {type: 'keyword', ignore_above: 256}}
},
abstract: {
type: 'text',
analyzer: 'standard',
fields: {keyword: {type: 'keyword', ignore_above: 256}}
},
embeddings: {
type: 'dense_vector',
dims: 3072,
index: true,
similarity: 'cosine',
index_options: {type: 'hnsw', m: 16, ef_construction: 100}
},
authors: {type: 'keyword'},
tags: {type: 'keyword'},
source: {type: 'keyword'},
processing_status: {type: 'keyword'},
metadata: {type: 'object', enabled: true},
evaluation_score: {
properties: {
relevance: {type: 'float'},
credibility: {type: 'float'},
clarity: {type: 'float'},
actionability: {type: 'float'},
aggregate: {type: 'float'}
}
},
created_at: {type: 'date'},
updated_at: {type: 'date'},
vectorized_at: {type: 'date'}
}
}
})
};
fetch('https://api.sophra.org/api/cortex/indices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/cortex/indices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '{{test_index_name}}',
'settings' => [
'number_of_shards' => 1,
'number_of_replicas' => 1,
'analysis' => [
'analyzer' => [
'default' => [
'type' => 'standard',
'stopwords' => '_english_'
]
]
]
],
'mappings' => [
'properties' => [
'title' => [
'type' => 'text',
'analyzer' => 'standard',
'fields' => [
'keyword' => [
'type' => 'keyword',
'ignore_above' => 256
]
]
],
'content' => [
'type' => 'text',
'analyzer' => 'standard',
'fields' => [
'keyword' => [
'type' => 'keyword',
'ignore_above' => 256
]
]
],
'abstract' => [
'type' => 'text',
'analyzer' => 'standard',
'fields' => [
'keyword' => [
'type' => 'keyword',
'ignore_above' => 256
]
]
],
'embeddings' => [
'type' => 'dense_vector',
'dims' => 3072,
'index' => true,
'similarity' => 'cosine',
'index_options' => [
'type' => 'hnsw',
'm' => 16,
'ef_construction' => 100
]
],
'authors' => [
'type' => 'keyword'
],
'tags' => [
'type' => 'keyword'
],
'source' => [
'type' => 'keyword'
],
'processing_status' => [
'type' => 'keyword'
],
'metadata' => [
'type' => 'object',
'enabled' => true
],
'evaluation_score' => [
'properties' => [
'relevance' => [
'type' => 'float'
],
'credibility' => [
'type' => 'float'
],
'clarity' => [
'type' => 'float'
],
'actionability' => [
'type' => 'float'
],
'aggregate' => [
'type' => 'float'
]
]
],
'created_at' => [
'type' => 'date'
],
'updated_at' => [
'type' => 'date'
],
'vectorized_at' => [
'type' => 'date'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/cortex/indices"
payload := strings.NewReader("{\n \"name\": \"{{test_index_name}}\",\n \"settings\": {\n \"number_of_shards\": 1,\n \"number_of_replicas\": 1,\n \"analysis\": {\n \"analyzer\": {\n \"default\": {\n \"type\": \"standard\",\n \"stopwords\": \"_english_\"\n }\n }\n }\n },\n \"mappings\": {\n \"properties\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"content\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"abstract\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"embeddings\": {\n \"type\": \"dense_vector\",\n \"dims\": 3072,\n \"index\": true,\n \"similarity\": \"cosine\",\n \"index_options\": {\n \"type\": \"hnsw\",\n \"m\": 16,\n \"ef_construction\": 100\n }\n },\n \"authors\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"source\": {\n \"type\": \"keyword\"\n },\n \"processing_status\": {\n \"type\": \"keyword\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"enabled\": true\n },\n \"evaluation_score\": {\n \"properties\": {\n \"relevance\": {\n \"type\": \"float\"\n },\n \"credibility\": {\n \"type\": \"float\"\n },\n \"clarity\": {\n \"type\": \"float\"\n },\n \"actionability\": {\n \"type\": \"float\"\n },\n \"aggregate\": {\n \"type\": \"float\"\n }\n }\n },\n \"created_at\": {\n \"type\": \"date\"\n },\n \"updated_at\": {\n \"type\": \"date\"\n },\n \"vectorized_at\": {\n \"type\": \"date\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/cortex/indices")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"{{test_index_name}}\",\n \"settings\": {\n \"number_of_shards\": 1,\n \"number_of_replicas\": 1,\n \"analysis\": {\n \"analyzer\": {\n \"default\": {\n \"type\": \"standard\",\n \"stopwords\": \"_english_\"\n }\n }\n }\n },\n \"mappings\": {\n \"properties\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"content\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"abstract\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"embeddings\": {\n \"type\": \"dense_vector\",\n \"dims\": 3072,\n \"index\": true,\n \"similarity\": \"cosine\",\n \"index_options\": {\n \"type\": \"hnsw\",\n \"m\": 16,\n \"ef_construction\": 100\n }\n },\n \"authors\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"source\": {\n \"type\": \"keyword\"\n },\n \"processing_status\": {\n \"type\": \"keyword\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"enabled\": true\n },\n \"evaluation_score\": {\n \"properties\": {\n \"relevance\": {\n \"type\": \"float\"\n },\n \"credibility\": {\n \"type\": \"float\"\n },\n \"clarity\": {\n \"type\": \"float\"\n },\n \"actionability\": {\n \"type\": \"float\"\n },\n \"aggregate\": {\n \"type\": \"float\"\n }\n }\n },\n \"created_at\": {\n \"type\": \"date\"\n },\n \"updated_at\": {\n \"type\": \"date\"\n },\n \"vectorized_at\": {\n \"type\": \"date\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/cortex/indices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"{{test_index_name}}\",\n \"settings\": {\n \"number_of_shards\": 1,\n \"number_of_replicas\": 1,\n \"analysis\": {\n \"analyzer\": {\n \"default\": {\n \"type\": \"standard\",\n \"stopwords\": \"_english_\"\n }\n }\n }\n },\n \"mappings\": {\n \"properties\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"content\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"abstract\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"embeddings\": {\n \"type\": \"dense_vector\",\n \"dims\": 3072,\n \"index\": true,\n \"similarity\": \"cosine\",\n \"index_options\": {\n \"type\": \"hnsw\",\n \"m\": 16,\n \"ef_construction\": 100\n }\n },\n \"authors\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"source\": {\n \"type\": \"keyword\"\n },\n \"processing_status\": {\n \"type\": \"keyword\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"enabled\": true\n },\n \"evaluation_score\": {\n \"properties\": {\n \"relevance\": {\n \"type\": \"float\"\n },\n \"credibility\": {\n \"type\": \"float\"\n },\n \"clarity\": {\n \"type\": \"float\"\n },\n \"actionability\": {\n \"type\": \"float\"\n },\n \"aggregate\": {\n \"type\": \"float\"\n }\n }\n },\n \"created_at\": {\n \"type\": \"date\"\n },\n \"updated_at\": {\n \"type\": \"date\"\n },\n \"vectorized_at\": {\n \"type\": \"date\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_bodyCortex > Index Management
Create Index
POST
/
cortex
/
indices
Create Index
curl --request POST \
--url https://api.sophra.org/api/cortex/indices \
--header 'Content-Type: application/json' \
--data '
{
"name": "{{test_index_name}}",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"default": {
"type": "standard",
"stopwords": "_english_"
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "standard",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"content": {
"type": "text",
"analyzer": "standard",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"abstract": {
"type": "text",
"analyzer": "standard",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"embeddings": {
"type": "dense_vector",
"dims": 3072,
"index": true,
"similarity": "cosine",
"index_options": {
"type": "hnsw",
"m": 16,
"ef_construction": 100
}
},
"authors": {
"type": "keyword"
},
"tags": {
"type": "keyword"
},
"source": {
"type": "keyword"
},
"processing_status": {
"type": "keyword"
},
"metadata": {
"type": "object",
"enabled": true
},
"evaluation_score": {
"properties": {
"relevance": {
"type": "float"
},
"credibility": {
"type": "float"
},
"clarity": {
"type": "float"
},
"actionability": {
"type": "float"
},
"aggregate": {
"type": "float"
}
}
},
"created_at": {
"type": "date"
},
"updated_at": {
"type": "date"
},
"vectorized_at": {
"type": "date"
}
}
}
}
'import requests
url = "https://api.sophra.org/api/cortex/indices"
payload = {
"name": "{{test_index_name}}",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"analysis": { "analyzer": { "default": {
"type": "standard",
"stopwords": "_english_"
} } }
},
"mappings": { "properties": {
"title": {
"type": "text",
"analyzer": "standard",
"fields": { "keyword": {
"type": "keyword",
"ignore_above": 256
} }
},
"content": {
"type": "text",
"analyzer": "standard",
"fields": { "keyword": {
"type": "keyword",
"ignore_above": 256
} }
},
"abstract": {
"type": "text",
"analyzer": "standard",
"fields": { "keyword": {
"type": "keyword",
"ignore_above": 256
} }
},
"embeddings": {
"type": "dense_vector",
"dims": 3072,
"index": True,
"similarity": "cosine",
"index_options": {
"type": "hnsw",
"m": 16,
"ef_construction": 100
}
},
"authors": { "type": "keyword" },
"tags": { "type": "keyword" },
"source": { "type": "keyword" },
"processing_status": { "type": "keyword" },
"metadata": {
"type": "object",
"enabled": True
},
"evaluation_score": { "properties": {
"relevance": { "type": "float" },
"credibility": { "type": "float" },
"clarity": { "type": "float" },
"actionability": { "type": "float" },
"aggregate": { "type": "float" }
} },
"created_at": { "type": "date" },
"updated_at": { "type": "date" },
"vectorized_at": { "type": "date" }
} }
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '{{test_index_name}}',
settings: {
number_of_shards: 1,
number_of_replicas: 1,
analysis: {analyzer: {default: {type: 'standard', stopwords: '_english_'}}}
},
mappings: {
properties: {
title: {
type: 'text',
analyzer: 'standard',
fields: {keyword: {type: 'keyword', ignore_above: 256}}
},
content: {
type: 'text',
analyzer: 'standard',
fields: {keyword: {type: 'keyword', ignore_above: 256}}
},
abstract: {
type: 'text',
analyzer: 'standard',
fields: {keyword: {type: 'keyword', ignore_above: 256}}
},
embeddings: {
type: 'dense_vector',
dims: 3072,
index: true,
similarity: 'cosine',
index_options: {type: 'hnsw', m: 16, ef_construction: 100}
},
authors: {type: 'keyword'},
tags: {type: 'keyword'},
source: {type: 'keyword'},
processing_status: {type: 'keyword'},
metadata: {type: 'object', enabled: true},
evaluation_score: {
properties: {
relevance: {type: 'float'},
credibility: {type: 'float'},
clarity: {type: 'float'},
actionability: {type: 'float'},
aggregate: {type: 'float'}
}
},
created_at: {type: 'date'},
updated_at: {type: 'date'},
vectorized_at: {type: 'date'}
}
}
})
};
fetch('https://api.sophra.org/api/cortex/indices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/cortex/indices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '{{test_index_name}}',
'settings' => [
'number_of_shards' => 1,
'number_of_replicas' => 1,
'analysis' => [
'analyzer' => [
'default' => [
'type' => 'standard',
'stopwords' => '_english_'
]
]
]
],
'mappings' => [
'properties' => [
'title' => [
'type' => 'text',
'analyzer' => 'standard',
'fields' => [
'keyword' => [
'type' => 'keyword',
'ignore_above' => 256
]
]
],
'content' => [
'type' => 'text',
'analyzer' => 'standard',
'fields' => [
'keyword' => [
'type' => 'keyword',
'ignore_above' => 256
]
]
],
'abstract' => [
'type' => 'text',
'analyzer' => 'standard',
'fields' => [
'keyword' => [
'type' => 'keyword',
'ignore_above' => 256
]
]
],
'embeddings' => [
'type' => 'dense_vector',
'dims' => 3072,
'index' => true,
'similarity' => 'cosine',
'index_options' => [
'type' => 'hnsw',
'm' => 16,
'ef_construction' => 100
]
],
'authors' => [
'type' => 'keyword'
],
'tags' => [
'type' => 'keyword'
],
'source' => [
'type' => 'keyword'
],
'processing_status' => [
'type' => 'keyword'
],
'metadata' => [
'type' => 'object',
'enabled' => true
],
'evaluation_score' => [
'properties' => [
'relevance' => [
'type' => 'float'
],
'credibility' => [
'type' => 'float'
],
'clarity' => [
'type' => 'float'
],
'actionability' => [
'type' => 'float'
],
'aggregate' => [
'type' => 'float'
]
]
],
'created_at' => [
'type' => 'date'
],
'updated_at' => [
'type' => 'date'
],
'vectorized_at' => [
'type' => 'date'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/cortex/indices"
payload := strings.NewReader("{\n \"name\": \"{{test_index_name}}\",\n \"settings\": {\n \"number_of_shards\": 1,\n \"number_of_replicas\": 1,\n \"analysis\": {\n \"analyzer\": {\n \"default\": {\n \"type\": \"standard\",\n \"stopwords\": \"_english_\"\n }\n }\n }\n },\n \"mappings\": {\n \"properties\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"content\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"abstract\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"embeddings\": {\n \"type\": \"dense_vector\",\n \"dims\": 3072,\n \"index\": true,\n \"similarity\": \"cosine\",\n \"index_options\": {\n \"type\": \"hnsw\",\n \"m\": 16,\n \"ef_construction\": 100\n }\n },\n \"authors\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"source\": {\n \"type\": \"keyword\"\n },\n \"processing_status\": {\n \"type\": \"keyword\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"enabled\": true\n },\n \"evaluation_score\": {\n \"properties\": {\n \"relevance\": {\n \"type\": \"float\"\n },\n \"credibility\": {\n \"type\": \"float\"\n },\n \"clarity\": {\n \"type\": \"float\"\n },\n \"actionability\": {\n \"type\": \"float\"\n },\n \"aggregate\": {\n \"type\": \"float\"\n }\n }\n },\n \"created_at\": {\n \"type\": \"date\"\n },\n \"updated_at\": {\n \"type\": \"date\"\n },\n \"vectorized_at\": {\n \"type\": \"date\"\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/cortex/indices")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"{{test_index_name}}\",\n \"settings\": {\n \"number_of_shards\": 1,\n \"number_of_replicas\": 1,\n \"analysis\": {\n \"analyzer\": {\n \"default\": {\n \"type\": \"standard\",\n \"stopwords\": \"_english_\"\n }\n }\n }\n },\n \"mappings\": {\n \"properties\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"content\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"abstract\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"embeddings\": {\n \"type\": \"dense_vector\",\n \"dims\": 3072,\n \"index\": true,\n \"similarity\": \"cosine\",\n \"index_options\": {\n \"type\": \"hnsw\",\n \"m\": 16,\n \"ef_construction\": 100\n }\n },\n \"authors\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"source\": {\n \"type\": \"keyword\"\n },\n \"processing_status\": {\n \"type\": \"keyword\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"enabled\": true\n },\n \"evaluation_score\": {\n \"properties\": {\n \"relevance\": {\n \"type\": \"float\"\n },\n \"credibility\": {\n \"type\": \"float\"\n },\n \"clarity\": {\n \"type\": \"float\"\n },\n \"actionability\": {\n \"type\": \"float\"\n },\n \"aggregate\": {\n \"type\": \"float\"\n }\n }\n },\n \"created_at\": {\n \"type\": \"date\"\n },\n \"updated_at\": {\n \"type\": \"date\"\n },\n \"vectorized_at\": {\n \"type\": \"date\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/cortex/indices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"{{test_index_name}}\",\n \"settings\": {\n \"number_of_shards\": 1,\n \"number_of_replicas\": 1,\n \"analysis\": {\n \"analyzer\": {\n \"default\": {\n \"type\": \"standard\",\n \"stopwords\": \"_english_\"\n }\n }\n }\n },\n \"mappings\": {\n \"properties\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"content\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"abstract\": {\n \"type\": \"text\",\n \"analyzer\": \"standard\",\n \"fields\": {\n \"keyword\": {\n \"type\": \"keyword\",\n \"ignore_above\": 256\n }\n }\n },\n \"embeddings\": {\n \"type\": \"dense_vector\",\n \"dims\": 3072,\n \"index\": true,\n \"similarity\": \"cosine\",\n \"index_options\": {\n \"type\": \"hnsw\",\n \"m\": 16,\n \"ef_construction\": 100\n }\n },\n \"authors\": {\n \"type\": \"keyword\"\n },\n \"tags\": {\n \"type\": \"keyword\"\n },\n \"source\": {\n \"type\": \"keyword\"\n },\n \"processing_status\": {\n \"type\": \"keyword\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"enabled\": true\n },\n \"evaluation_score\": {\n \"properties\": {\n \"relevance\": {\n \"type\": \"float\"\n },\n \"credibility\": {\n \"type\": \"float\"\n },\n \"clarity\": {\n \"type\": \"float\"\n },\n \"actionability\": {\n \"type\": \"float\"\n },\n \"aggregate\": {\n \"type\": \"float\"\n }\n }\n },\n \"created_at\": {\n \"type\": \"date\"\n },\n \"updated_at\": {\n \"type\": \"date\"\n },\n \"vectorized_at\": {\n \"type\": \"date\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_bodyBody
application/json
The body is of type object.
Response
200 - application/json
Successful response

